package basic;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {

	public static void main(String[] args){
		Connection conn = null;
		PreparedStatement pstmt=null;
		try {
		new oracle.jdbc.driver.OracleDriver();
		//Class.forName("oracle.jdbc.driver.OracleDriver")
		conn = DriverManager.getConnection("jdbc:oracle:thin:@172.16.0.6:1521:tangjl","openlab","open123");
		conn.setAutoCommit(false);
		pstmt = 
			conn.prepareStatement("update classes_sls set name='slsadd' where id=?");
		pstmt.setInt(1, 3);
		pstmt.execute();
		
		pstmt.setInt(2, 10);
		pstmt.execute();
//		rs.next();
//		System.out.println(rs.getInt(1)+"---"+rs.getString(2));
		System.out.println("hello");
		conn.commit();
		}catch(Exception e){
			try {
				conn.rollback();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}finally{
			try {
				if(pstmt!=null)
				pstmt.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try {
				if(conn!=null)
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println("hello");
		}
		
	}

}
